﻿package com.litong;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

// HttpServlet
public class ThirdServlet extends HttpServlet
{
	private String message;
	
	public void init() throws ServletException{
		message = "Hello World";
		System.out.println(message);
	}

	protected void doGet(HttpServletRequest req,
                     	HttpServletResponse resp)
                     	throws ServletException, java.io.IOException{
		resp.setContentType("text/html;charset=utf-8");
		resp.setContentType("text/html");
		PrintWriter out = resp.getWriter();
		String html = "<!doctype HTML><html><head><meat charset=\"utf-8\"></head><body>";
		String content ="<h1>i am httpServet doGet()"+req.getParameter("username")+"</h1>";
		String end = "</body></html>";
		out.println(html+content+end);		
	}
	protected void doPost(HttpServletRequest req,
                      HttpServletResponse resp)
               throws ServletException, java.io.IOException{ 
		resp.getWriter().println("i am httpServet doPost() post name="+req.getParameter("username"));
	}
	
	public void destroy() {
		System.out.println("servlet销毁");
		super.destroy();
	
	}
}